﻿using System;

namespace dPet.Domain.Models
{
	using Hangerd;
	using Hangerd.Entity;

	public class SaleOrderLine : EntityBase
	{
		#region Public Properties

		/// <summary>
		/// 商品条码
		/// </summary>
		public string ProductBarcode { get; private set; }

		/// <summary>
		/// 商品名称
		/// </summary>
		public string ProductName { get; private set; }

		/// <summary>
		/// 商品单价
		/// </summary>
		public decimal UnitPrice { get; private set; }

		/// <summary>
		/// 单位名称
		/// </summary>
		public string UnitName { get; private set; }

		/// <summary>
		/// 商品数量
		/// </summary>
		public int Quantity { get; private set; }
	
		#endregion

		#region Constructors

		private SaleOrderLine() { }

		public SaleOrderLine(Product product, int quantity)
		{
			if (quantity < 1)
			{
				throw new HangerdException("商品 [{0}] 数量不可小于1", product.Name);
			}

			this.ProductBarcode = product.Barcode;
			this.ProductName = product.Name;
			this.UnitPrice = product.UnitPrice;
			this.UnitName = product.UnitName;
			this.Quantity = quantity;
		}

		#endregion

		#region Public Methods

		#endregion
	}
}
